package com.shujia.controller;

import com.shujia.entity.Dept;
import com.shujia.dao.DeptServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/dept")
public class DeptController {

    @Autowired
    private DeptServiceImpl deptService;

    //声明日志成员
    private static final Logger log = LoggerFactory.getLogger(DeptController.class);

    /**
     * 获取所有部门信息
     * @return
     */
    //http://localhost:8083/bigdata17-pro/dept/all
    @RequestMapping(value = "/all",method = RequestMethod.GET)
    public List<Dept> getAllCusBaseInfo(){
        log.info("=================数加科技=================");

        return deptService.getAllCusBaseInfo();
    }

    /**
     * 保存部门信息
     * @param dept
     * @return
     */
    @RequestMapping(value = "/save",method = RequestMethod.POST)
    public Dept saveCusBaseInfo(Dept dept){

        return deptService.saveDeptInfo(dept);
    }

    /**
     * 根据客户ID查询部门信息
     * @param deptno
     * @return
     */
    @RequestMapping(value = "/get/{cusId}",method = RequestMethod.GET)
    public Dept getCusBaseInfoById(@PathVariable String deptno){
        return deptService.getDeptByNo(deptno);
    }

}
